package org.bw.bookstore.book.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.bw.bookstore.book.service.ShopService;
import org.bw.bookstore.common.entity.TbShop;
import org.bw.bookstore.common.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @program:server-store
 * @description:门店控制类
 * @author:guoshuai
 * @create:2020-10-27 09:00
 **/
@RestController
@CrossOrigin
@Slf4j
@RequestMapping("/shop")
@Api(tags = "接口-，门店管理")
public class ShopController {
    @Autowired
    ShopService shopService;
    /**
     * TODO 添加门店
     * @Description:
     * @Author: guoshuai
     * @Date: 2020-10-27 上午 09:06
     * @param shop: 要添加的门店信息
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @ApiOperation(value = "门店注册", notes = "门店注册")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "shopName", value = "店铺名字", dataType = "String", required = true),
            @ApiImplicitParam(name = "address", value = "店铺地址", dataType = "String", required = true),
            @ApiImplicitParam(name = "memberNum", value = "人员数量", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "StaffMemberCode", value = "店长code", dataType = "String", required = true),

    })
    @PostMapping("/addShop")
    public ResponseResult addShop(@ApiIgnore TbShop shop){
        return shopService.addShop(shop);
    };
    /**
     * TODO 删除门店
     * @Description:
     * @Author: guoshuai
     * @Date: 2020-10-27 上午 09:06
     * @param shopId: 要删除的门店id
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @ApiOperation(value = "门店下架", notes = "门店下架")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "shopId", value = "门店id", dataType = "Integer", required = true)
    })
    @PostMapping("/delShop")
    public ResponseResult deleteShop(Integer shopId){
        return shopService.deleteShop(shopId);
    };
    /**
     * TODO 门店信息修改
     * @Description:
     * @Author: guoshuai
     * @Date: 2020-10-27 上午 09:06
     * @param shop: 要添加的门店信息
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @ApiOperation(value = "门店信息修改", notes = "门店信息修改")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "店铺id", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "shopName", value = "店铺名字", dataType = "String", required = true),
            @ApiImplicitParam(name = "address", value = "店铺地址", dataType = "String", required = true),
            @ApiImplicitParam(name = "memberNum", value = "人员数量", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "StaffMemberCode", value = "店长code", dataType = "String", required = true)
    })
    @PostMapping("/updateShop")
    public ResponseResult updateShop(@ApiIgnore TbShop shop){
        return shopService.updateShop(shop);
    };
    /**
     * TODO 全部门店
     * @Description:
     * @Author: guoshuai
     * @Date: 2020-10-27 上午 09:06
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @PostMapping("/getShop")
    @ApiOperation(value = "查询门店信息", notes = "查询门店信息")
    public ResponseResult listShop(){
        return shopService.listShop();
    };
}
